/*
 * File: TimerTaskMgr.c
 *
 * Code generated for Simulink model 'TimerTaskMgr'.
 *
 * Model version                  : 1.24
 * Simulink Coder version         : 9.6 (R2021b) 14-May-2021
 * C/C++ source code generated on : Thu Jan 12 09:58:56 2023
 *
 * Target selection: ert.tlc
 * Embedded hardware selection: Intel->x86-64 (Windows64)
 * Code generation objectives: Unspecified
 * Validation result: Not run
 */

#include "TimerTaskMgr.h"
#include "TimerTaskMgr_private.h"

/* Block signals (default storage) */
B_TimerTaskMgr_T TimerTaskMgr_B;

/* Block states (default storage) */
DW_TimerTaskMgr_T TimerTaskMgr_DW;

/* External outputs (root outports fed by signals with default storage) */
ExtY_TimerTaskMgr_T TimerTaskMgr_Y;

/* Real-time model */
static RT_MODEL_TimerTaskMgr_T TimerTaskMgr_M_;
RT_MODEL_TimerTaskMgr_T *const TimerTaskMgr_M = &TimerTaskMgr_M_;

/* Model step function */
void TimerTaskMgr_step(void)
{
  uint32_T tmp;

  /* MATLAB Function: '<Root>/fnTimerTaskMgr' incorporates:
   *  Constant: '<Root>/Constant'
   */
  TimerTaskMgr_DW.obj.trigger[0] = false;
  if (TimerTaskMgr_DW.obj.cnter[1] >= 2) {
    if (TimerTaskMgr_DW.obj.cnter[1] - 2 >= 0) {
      TimerTaskMgr_DW.obj.cnter[1] = (uint16_T)(TimerTaskMgr_DW.obj.cnter[1] - 2);
    } else {
      TimerTaskMgr_DW.obj.cnter[1] = 0U;
    }

    TimerTaskMgr_DW.obj.trigger[1] = true;
  } else {
    tmp = TimerTaskMgr_DW.obj.cnter[1] + 1U;
    if (TimerTaskMgr_DW.obj.cnter[1] + 1U > 65535U) {
      tmp = 65535U;
    }

    TimerTaskMgr_DW.obj.cnter[1] = (uint16_T)tmp;
    TimerTaskMgr_DW.obj.trigger[1] = false;
  }

  if (TimerTaskMgr_DW.obj.cnter[2] >= 20) {
    if (TimerTaskMgr_DW.obj.cnter[2] - 20 >= 0) {
      TimerTaskMgr_DW.obj.cnter[2] = (uint16_T)(TimerTaskMgr_DW.obj.cnter[2] -
        20);
    } else {
      TimerTaskMgr_DW.obj.cnter[2] = 0U;
    }

    TimerTaskMgr_DW.obj.trigger[2] = true;
  } else {
    tmp = TimerTaskMgr_DW.obj.cnter[2] + 1U;
    if (TimerTaskMgr_DW.obj.cnter[2] + 1U > 65535U) {
      tmp = 65535U;
    }

    TimerTaskMgr_DW.obj.cnter[2] = (uint16_T)tmp;
    TimerTaskMgr_DW.obj.trigger[2] = false;
  }

  if (TimerTaskMgr_DW.obj.cnter[3] >= 200) {
    if (TimerTaskMgr_DW.obj.cnter[3] - 200 >= 0) {
      TimerTaskMgr_DW.obj.cnter[3] = (uint16_T)(TimerTaskMgr_DW.obj.cnter[3] -
        200);
    } else {
      TimerTaskMgr_DW.obj.cnter[3] = 0U;
    }

    TimerTaskMgr_DW.obj.trigger[3] = true;
  } else {
    tmp = TimerTaskMgr_DW.obj.cnter[3] + 1U;
    if (TimerTaskMgr_DW.obj.cnter[3] + 1U > 65535U) {
      tmp = 65535U;
    }

    TimerTaskMgr_DW.obj.cnter[3] = (uint16_T)tmp;
    TimerTaskMgr_DW.obj.trigger[3] = false;
  }

  TimerTaskMgr_B.re5ms = TimerTaskMgr_DW.obj.trigger[0];
  TimerTaskMgr_B.re10ms = TimerTaskMgr_DW.obj.trigger[1];
  TimerTaskMgr_B.re100ms = TimerTaskMgr_DW.obj.trigger[2];
  TimerTaskMgr_B.re1000ms = TimerTaskMgr_DW.obj.trigger[3];

  /* End of MATLAB Function: '<Root>/fnTimerTaskMgr' */

  /* Outputs for Enabled SubSystem: '<Root>/Raise5ms' */
  TimerTaskMgr_Raise5ms();

  /* End of Outputs for SubSystem: '<Root>/Raise5ms' */

  /* Outputs for Enabled SubSystem: '<Root>/Raise10ms' */
  TimerTaskMgr_Raise10ms();

  /* End of Outputs for SubSystem: '<Root>/Raise10ms' */

  /* Outputs for Enabled SubSystem: '<Root>/Raise100ms' */
  TimerTaskMgr_Raise100ms();

  /* End of Outputs for SubSystem: '<Root>/Raise100ms' */

  /* Outputs for Enabled SubSystem: '<Root>/Raise1000ms' */
  TimerTaskMgr_Raise1000ms();

  /* End of Outputs for SubSystem: '<Root>/Raise1000ms' */
}

/* Model initialize function */
void TimerTaskMgr_initialize(void)
{
  /* SystemInitialize for MATLAB Function: '<Root>/fnTimerTaskMgr' */
  TimerTaskMgr_DW.obj.cnter[0] = 0U;
  TimerTaskMgr_DW.obj.trigger[0] = false;
  TimerTaskMgr_DW.obj.cnter[1] = 0U;
  TimerTaskMgr_DW.obj.trigger[1] = false;
  TimerTaskMgr_DW.obj.cnter[2] = 0U;
  TimerTaskMgr_DW.obj.trigger[2] = false;
  TimerTaskMgr_DW.obj.cnter[3] = 0U;
  TimerTaskMgr_DW.obj.trigger[3] = false;
}

/* Model terminate function */
void TimerTaskMgr_terminate(void)
{
  /* (no terminate code required) */
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
